Content starts here How To Access Catalog Services
This page last changed on Mar 13, 2008.


edocs Home > BEA AquaLogic Data Services Platform 3.0 Documentation

How To Access Catalog Services

Author Chandrushekar Hebbasooru
Versions ALDSP 3.0, 3.2

Catalog services provide a convenient way for client-application developers to programmatically obtain information about ALDSP artifacts(dataspaces, data services, schemas,  functions and relationships). Catalog Services are also data services. This allows the client application developer to access catalog services as they would any other data service.

This section provides details about installing and using Catalog Services to access metadata for any ALDSP dataspace.

Topics

What this How-To Demonstrates

This how-to describes:

  • Organization of data services generated through catalog services.
  • How sample clients can access data services through dynamic and static APIs.

Background

Before you read through the next section, ensure that you have an understanding on how data services can be accessed from Java clients.

Invoking Data Services from Java Clients

Installing Catalog Services

Catalog Service data services are installed inside an existing dataspace project. Once installed, the catalog services folder (_catalogservices) contains data services that can be used to fetch metadata about dataspace project artifacts.

To install Catalog Services right-click any dataspace project and select Install Catalog Services.

The following data services will be created in the project's _catalogservices folder:

Data service Purpose
DataService (DataService.ds) Used to fetch the metadata about the data services in the dataspace.
Folder (Folder.ds) Used to fetch metadata about the folders in the dataspace.
Function (Function.ds) Used to fetch the metadata about the functions which are present in a data service.
Relationship (Relationship.ds) Used to fetch the relationship information in which the functions participate in.
Schema (Schema.ds) Used to fetch the metadata about the schemas in the dataspace.


Once installed, you can invoke the catalog service-related data service operations through the ALDSP Client Mediator API.

Information on catalog services function signatures and return types:
See: "Accessing Metadata Using Catalog Services" in Advanced Topics

Accessing Catalog Services

Catalog Services data services can be accessed through the ALDSP mediator API dynamic or static interface.

Accessing Catalog Service Information Dynamically

The following sample demonstrates how to access the "getDataServiceRefs" function of a data service named DataService dynamically.

public class SampleCS {

    public static Context createContext() throws NamingException {
        Hashtable ctxTable = new Hashtable();
        ctxTable.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
        ctxTable.put(Context.PROVIDER_URL, "t3://localhost:7001");
        ctxTable.put(Context.SECURITY_PRINCIPAL, "weblogic");
        ctxTable.put(Context.SECURITY_CREDENTIALS, "weblogic");
        return new InitialContext(ctxTable);
    }

    public static void main(String[] args) throws Exception {
        Context context = createContext();
        String dsName = "ld:_catalogservices/DataService"; // Line #3
        String appName = "PublicMetadataAPI";
        DataAccessService das = DataAccessServiceFactory.newDataAccessService(context, appName, dsName);
        DASResult<Object> dasResult =  das.invoke("getDataServiceRefs", null); //Line #2
        while (dasResult.hasNext()) {
            DataObjectGeneral dObjGeneral = (DataObjectGeneral) dasResult.next();
            DataObject dObject = dObjGeneral.getRootObject();
            String id = (String) dObject.get("id"); //Line#3
            System.out.println("ID = " + id);
        }
    }

In the above code there are several lines marked with comments and associated with numbers.

  • Line #1 contains a reference to the DataService.ds which is present in the dataspace application named PublicMetadataAPI
  • Line #2 invokes the operation getDataServiceRefs on DataService.ds
  • Line #3 prints the id of each of the data services present in the application.

Compiling and Running the sample.

Compile and run the sample with the client classpath.

Accessing Catalog Service Information Statically

Create the Mediator Client JAR File through these steps:

  1. Right-click the dataspace project in Data Services Studio and select Export.
  2. Select AquaLogic Data Services Platform > Mediator Client JAR File.
  3. Select the path to export the JAR file.
  4. Name the file.
  5. Complete the wizard by creating a JAR file with the default name:

    <appname>-dsp-client.jar

The following sample demonstrates how to access the "getDataServiceRefs" function of the "DataService" DS statically:

public class StaticCS {
    public static Context createContext() throws NamingException {
        Hashtable ctxTable = new Hashtable();
        ctxTable.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
        ctxTable.put(Context.PROVIDER_URL, "t3://localhost:7001");
        ctxTable.put(Context.SECURITY_PRINCIPAL, "weblogic");
        ctxTable.put(Context.SECURITY_CREDENTIALS, "weblogic");
        return new InitialContext(ctxTable);
    }

    public static void main(String[] args) throws Exception {
        Context context = createContext();
        String appName = "PublicMetadataAPI";
        DataServiceDAS das = DataServiceDAS.getInstance(createContext(),appName); //Line #1
        DASResult<DataServiceRef> result = das.getDataServiceRefs(); //Line #2
        while (result.hasNext())
        {
            DataServiceRef ref = result.next(); //Line #3
            System.out.println("ref.getId() = " + ref.getId());
        }
    }
}

In the above code, Line #3 shows the casting of the result to the specific type: i.e. DataServiceRef instead of the generic DataObject.

Compile and run the sample with the client classpath.  
 

Additional References, Considerations, and Caveats

"Accessing Metadata Using Catalog Services" in Advanced Topics.

Install.jpg (image/jpeg)
Installed VIew.JPG (image/jpeg)
dynamicrun.JPG (image/jpeg)
staticrun.JPG (image/jpeg)
Document generated by Confluence on Apr 28, 2008 16:27